home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-26 | 3.1 KB | 120 lines | [TEXT/KAHL] |
- /* AMUtilities.c - common AppMaker library routines */
- /* Copyright © 1991, Bowers Development Corporation. */
-
- #include <CEditText.h>
- #include <CButton.h>
- #include <CTextEnvirons.h>
- #include <TBUtilities.h>
- #include <CError.h>
- #include "AMUtilities.h"
-
- /*----------*/
- void AMSetFontSizeStyle (CEditText *textObject,
- EditStylesP p)
- {
- textObject->SetFontSize (p->editStyles.textSize);
- textObject->SetFontStyle (NOTHING); // clear it out then set it
- textObject->SetFontStyle (p->editStyles.textStyle);
- textObject->SetAlignment (p->textJust);
- textObject->SetFontNumber (AMGetFontNum (p->editStyles.fontName));
-
- } /* AMSetFontSizeStyle */
-
- /*----------*/
- void AMSetTextID (CEditText *textObject,
- short textID)
- {
- Handle theText;
-
- if (textID > 0) { /* there is a TEXT resource */
- theText = GetResource ('TEXT', textID);
- CheckResource (theText);
- textObject->SetTextHandle (theText);
- ReleaseResource (theText);
- }
-
- } /* AMSetTextID */
-
- /*----------*/
- short AMGetFontNum (Str255 fontName)
- {
- short fontNum;
-
- if (fontName [0] == 0) {
- fontNum = systemFont;
- } else if (EqualString (fontName, "\pA", FALSE, TRUE)) {
- fontNum = applFont;
- } else {
- GetFNum (fontName, &fontNum);
- }
- return (fontNum);
-
- } /* AMGetFontNum */
-
- /*----------*/
- void AMSetupTextEnvirons (CPane *thePane,
- StylesP p)
- {
- CTextEnvirons *textEnvirons;
- TextInfoRec textInfo;
-
- /* create the text environment, using information from the control pane */
- textEnvirons = new CTextEnvirons;
- thePane->itsEnvironment = textEnvirons;
- textEnvirons->ITextEnvirons ();
-
- textInfo.fontNumber = AMGetFontNum (p->fontName);
- textInfo.theSize = p->textSize;
- textInfo.theStyle = p->textStyle;
- textInfo.theMode = srcOr;
- textEnvirons->SetTextInfo (&textInfo);
-
- } /* AMSetupTextEnvirons */
-
- /*----------*/
- void IAMControlPane (CButton *controlObject,
- CView *anEnclosure,
- CBureaucrat *aSupervisor,
- Ptr viewData)
- {
- register AMCtlPaneTempP p;
- short strSize;
- StylesP stylesPtr;
-
- /* initialize the superclass */
- /* all control panes, as subclasses of CButton, call INewButton */
- /* so that the procID can be specified. */
-
- p = (AMCtlPaneTempP) viewData;
- controlObject->INewButton (p->sPaneTemp.width, p->sPaneTemp.height,
- p->sPaneTemp.hEncl, p->sPaneTemp.vEncl,
- p->title, (p->sPaneTemp.sViewTemp.visible != 0), p->procID,
- anEnclosure, aSupervisor);
-
- if (p->sPaneTemp.sViewTemp.wantsClicks == 0) {
- controlObject->Deactivate ();
- }
-
- // Note: some fields of the ctlPane template are ignored.
- // The related instance variables are set to standard values:
- // hSizing = vSizing = sizFIXEDSTICKY
- // autoRefresh = TRUE;
- // printClip = clipFRAME;
- // wantsClicks = TRUE;
-
- strSize = 1 + p->title [0];
- strSize += (strSize & 1); // bump to even number
- stylesPtr = (StylesP) &p->title [strSize];
- AMSetupTextEnvirons (controlObject, stylesPtr);
-
- /* set the control values using information from the control pane */
- controlObject->SetMinValue (p->minValue);
- controlObject->SetMaxValue (p->maxValue);
- controlObject->SetValue (p->curValue);
-
- controlObject->SetClickCmd (p->clickCmd);
-
- } /* IAMControlPane */
-
- /* AMUtilities */
-